<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
	<head>
		<title>开放|关闭服务器</title>
		<base href="<%=basePath%>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<meta name="apple-mobile-web-app-title" content="Amaze UI" />
		<link rel="stylesheet" href="layui/css/layui.css" media="all"> <!-- 适应所有设备 -->
		<style type="text/css">
		</style>
	</head>
	<% String nowDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); %>
	<body>
	    <table class="layui-hide" id="ZoneState" lay-filter="ZoneState"></table>
	    
	    <script type="text/html" id="modify">
          <a class="layui-btn  layui-btn-xs" lay-event="edit">编辑</a>
        </script>
	    
	    <script src="js/jquery.min.js"></script>
		<script src="layui/layui.js"></script>
		<script>
		    layui.use(['layer','form','table'],function(){
		    	var layer = layui.layer,
		    	    form  = layui.form,
		    	    table = layui.table;
		    	table.render({
		    		elem:'#ZoneState',
		    		url:'admin/getChangeState',
		    		method:'post',
		    		title:'渠道',
		    		height: 'full-200',
		    		skin: 'row',
		    		even: true,
		    		id:'AllTable',
		    		cellMinWidth : 100,
		    		cols:[[
		    			{field:'state',title:'服务器状态',style:'color:red'},
		    			{field:'OpenTime',title:'时间',style:'color:blue'},
		    			{fixed:'right',title:'操作 ',toolbar: '#modify'}
		    			]],
		    			page : false,//分页
						response : {
							statusCode : 200
						//重新规定成功的状态码为 200，table 组件默认为 0
						},
						parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
							return {
								"code" : res.status, //解析接口状态
								"msg" : res.message, //解析提示文本
								"count" : res.count, //解析数据长度
								"data" : res.data
							//解析数据列表
							};
						}
		    	});
		    	
		    	//监听行工具事件
		    	table.on('tool(ZoneState)',function(obj){
		    		var data = obj.data;
		    		if(obj.event === 'edit'){
		    			layer.confirm('关闭服务器,<span style="color:red;">如果想在指定时间开放,请选择时间！</span><br/>如果不确定开放时间,<sapn style="color:red;">不用选择时间</span><br/>开放服务器,<sapn style="color:red;">不用选择时间</span>',{
							btn:['我已了解','退出']//按钮
						},function(index){
			    			var index = layer.open({
								type: 2,
								shadeClose: true,
								shade: 0.5,
								area: ['600px', '400px'],
								title: '设置服务器状态',
								skin: 'layer-ext-yourskin',
								content: '<%=basePath%>admin/toSetZoneState',
								success: function(layero,index,resp) {
									/* $.ajax({
						    			url:'admin/SetZoneState',
						    			async:true,
						    			type:'POST'
						    		}); */
								}
							});
						},function(){
						});
		    		}
		    	});
		    	
		    });
		</script>
    </body>
</html>